package cn.iocoder.yudao.module.erp.controller.admin.saleorder.vo;

import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "管理后台 - 销售订单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class SaleOrderRespVO {

    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long id;

    @Schema(description = "销售单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("销售单号")
    private String billNo;

    @Schema(description = "销售日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("销售日期")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @ColumnWidth(20)
    private LocalDateTime billDate;

    @Schema(description = "销售方")
    @ExcelProperty("销售方")
    private String billContacter;

    @Schema(description = "销售员", example = "李四")
    @ExcelProperty("销售员")
    private String billContacterName;

    @Schema(description = "销售员电话")
    @ExcelProperty("销售员电话")
    private String billContacterMobile;

    @Schema(description = "仓库名称", example = "张三")
    @ExcelProperty("仓库名称")
    private String warehouseName;

    @Schema(description = "仓库id", example = "1")
    private Long warehouseId;

    @Schema(description = "客户订单号")
    @ExcelProperty("客户订单号")
    private String customerOrderNo;

    @Schema(description = "客户名称（公司）", example = "赵六")
    @ExcelProperty("客户名称（公司）")
    private String customerName;

    @Schema(description = "客户id", example = "1")
    private Long customerId;

    @Schema(description = "客户联系人", example = "李四")
    @ExcelProperty("客户联系人")
    private String customerContacterName;

    @Schema(description = "联系电话")
    @ExcelProperty("联系电话")
    private String customerMobile;

    @Schema(description = "总数量")
    @ExcelProperty("总数量")
    private BigDecimal aggregateQuantity;

    @Schema(description = "总金额")
    @ExcelProperty("总金额")
    private BigDecimal aggregateAmount;

    @Schema(description = "优惠金额")
    @ExcelProperty("优惠金额")
    private BigDecimal discountAmount;

    @Schema(description = "优惠后总金额")
    @ExcelProperty("优惠后总金额")
    private BigDecimal totalAmount;

    @Schema(description = "交付地址")
    @ExcelProperty("交付地址")
    private String deliveryAddress;

    @Schema(description = "项目名称", example = "张三")
    @ExcelProperty("项目名称")
    private String projectName;

    @Schema(description = "项目id", example = "1")
    private Long projectId;

    @Schema(description = "结算方式", example = "张三")
    @ExcelProperty("结算方式")
    private String settlementName;

    @Schema(description = "结算id", example = "1")
    private Long settlementId;

    @Schema(description = "备注")
    @ExcelProperty("备注")
    private String remarks;

    @Schema(description = "附件")
    private String file;

    @Schema(description = "是否采购", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "是否采购",converter = DictConvert.class)
    @DictFormat(DictTypeConstants.ERP_PURCHSE_TYPE)
    private Boolean syncPurchase;

    @Schema(description = "是否收款", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "是否收款",converter = DictConvert.class)
    @DictFormat(DictTypeConstants.ERP_COLLECTION_TYPE)
    private Boolean syncPay;

    @Schema(description = "是否出库", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "是否出库",converter = DictConvert.class)
    @DictFormat(DictTypeConstants.ERP_OUTBOUND_TYPE)
    private Boolean syncOut;

    @Schema(description = "是否开票", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "是否开票", converter = DictConvert.class)
    @DictFormat(DictTypeConstants.ERP_INVOICING_TYPE)
    private Boolean syncInvoice;

    @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
    private String creator;

    @Schema(description = "添加时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("添加时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @ColumnWidth(20)
    private LocalDateTime createTime;

    @Schema(description = "修改人", requiredMode = Schema.RequiredMode.REQUIRED)
    private String updater;

    @Schema(description = "修改时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("修改时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @ColumnWidth(20)
    private LocalDateTime updateTime;

    @Schema(description = "报价有效时间")
    private  LocalDateTime expireTime;

    @Schema(description = "销售订单商品(弃用，改用goodsInfo)")
    private List<Item> saleOrderGoodsDOS;

    @Schema(description = "销售订单商品信息")
    private String goodsInfo;

    @Data
    public static class Item {
        @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8938")
        @ExcelProperty("id")
        private Long id;

        @Schema(description = "物品编号", requiredMode = Schema.RequiredMode.REQUIRED)
        @ExcelProperty("物品编号")
        private String code;

        @Schema(description = "物品规格型号")
        @ExcelProperty("物品规格型号")
        private String models;

        @Schema(description = "英文名称")
        @ExcelProperty("英文名称")
        private String nameEn;

        @Schema(description = "交付日期")
        @ExcelProperty("交付日期")
        private LocalDateTime deliveryData;

        @Schema(description = "备注")
        @ExcelProperty("备注")
        private String remarks;

        @Schema(description = "添加时间", requiredMode = Schema.RequiredMode.REQUIRED)
        @ExcelProperty("添加时间")
        private LocalDateTime createTime;

        @Schema(description = "物品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
        @ExcelProperty("物品名称")
        private String name;

        @Schema(description = "仓库id", example = "24017")
        @ExcelProperty("仓库id")
        private Long warehouseId;

        @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
        @ExcelProperty("数量")
        private BigDecimal number;

        @Schema(description = "税率")
        @ExcelProperty("税率")
        private BigDecimal taxRate;

        @Schema(description = "未税单价", example = "28711")
        @ExcelProperty("未税单价")
        private BigDecimal noTaxPrice;

        @Schema(description = "未税总额")
        @ExcelProperty("未税总额")
        private BigDecimal noTaxTotal;

        @Schema(description = "税额")
        @ExcelProperty("税额")
        private BigDecimal tax;

        @Schema(description = "单价", example = "19686")
        @ExcelProperty("单价")
        private BigDecimal price;

        @Schema(description = "价税总额")
        @ExcelProperty("价税总额")
        private BigDecimal total;

        @Schema(description = "单位成本")
        @ExcelProperty("单位成本")
        private BigDecimal unitCost;

        @Schema(description = "出库数量", requiredMode = Schema.RequiredMode.REQUIRED)
        @ExcelProperty("出库数量")
        private BigDecimal outNum;

        @Schema(description = "退货数量")
        @ExcelProperty("退货数量")
        private BigDecimal inNum;

        @Schema(description = "未出库数量", requiredMode = Schema.RequiredMode.REQUIRED)
        @ExcelProperty("未出库数量")
        private BigDecimal noOutNum;

        @Schema(description = "计划生产数量")
        @ExcelProperty("计划生产数量")
        private BigDecimal planNum;

        @Schema(description = "排产数量")
        @ExcelProperty("排产数量")
        private BigDecimal workNum;
    }

}